package com.lg.desireplayer.bandinfo;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.lg.desireplayer.R;
import com.lg.desireplayer.bandlist.BandList;
import com.lg.desireplayer.util.GetImageFromURL;

public class ViewBandinfo extends Activity{
	private TextView tName;
	private ImageView iBandImg;
	private TextView tTitle;
	private TextView tInfo;
	private TextView tLike;
	private Button bPlay;
	private Intent Intent2Main;
	private Intent IntentFromMain;
	private int id;
	Bitmap imgBitmap=null;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bandinfo);
		
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
		.detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());

		tName=(TextView)findViewById(R.id.VeiwBandinfo_textview_bandname);
		tTitle=(TextView)findViewById(R.id.VeiwBandinfo_textview_bandtitle);
		tInfo=(TextView)findViewById(R.id.VeiwBandinfo_textview_bandinfo);
		iBandImg=(ImageView)findViewById(R.id.VeiwBandinfo_imageview_bandimage);
		bPlay=(Button)findViewById(R.id.VeiwBandinfo_button_play_move);
		tLike = (TextView)findViewById(R.id.VeiwBandinfo_textview_like);
		Intent2Main=new Intent(ViewBandinfo.this,com.lg.desireplayer.main.Main.class);
		
		IntentFromMain=getIntent();				//Main Activity로 부터의 호출 감지
		
		id=IntentFromMain.getExtras().getInt("id");   //id 값을 추출
		
		if(IntentFromMain.hasExtra("main"))
				{
					bPlay.setVisibility(View.INVISIBLE);
				}
		
			
		
		
	
		
		///////////////////////////iamge call///////////////
		
		 imgBitmap=GetImageFromURL.setImage(BandList.retrieveBand(id).getId());
		
		

		if (imgBitmap != null)

		{
			tLike.setText(Integer.toString(BandList.retrieveBand(id).getLikecnt()));
			iBandImg.setImageBitmap(imgBitmap);
			tName.setText(BandList.retrieveBand(id).getName());
			tTitle.setText(BandList.retrieveBand(id).getTitle());
			tInfo.setText(BandList.retrieveBand(id).getDescr());

		}
		else Toast.makeText(ViewBandinfo.this, "서버 상태를 확인 해 주세요", 0).show();
		

		bPlay.setOnClickListener(new Button.OnClickListener(){

			@Override
			public void onClick(View arg0) {
				Intent2Main.putExtra("Bandinfo", BandList.retrieveBand(id).getId());
				Log.i("id",""+BandList.retrieveBand(id).getId());
				
				startActivity(Intent2Main);
				
				
			}
			
		});
		
		
	}



	

}
